//防抖函数
function debounce(fn, delay) {
    let timer
    return (...args) => {
       clearTimeout(timer)
       timer = setTimeout(()=>{
            fn.apply(this, args)
        }, delay)
    }
}


//节流函数

function throttle(fn, delay) {
    let flag = true
    return (...args) => {
        if(!flag) return;
        flag = false
        setTimeout(() => {
            fn.apply(this, args)
            flag = true
        }, delay);
    }
}

